#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi

#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > cc2_r12_aux2_bh_lhtr.info <<'%EOF%'
   cc2_r12_aux2_bh_lhtr
   -----------
   Molecule:         BH 
   Wave Function:    CC2-R12/A1/A / AhlrichsVDZ + AhlrichsVTZ-Auxbasis
   Test Purpose:     Check CC2-R12/A1/A method with auxiliary basis (and LHTR)
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > cc2_r12_aux2_bh_lhtr.mol <<'%EOF%'
BASIS
Ahlrichs-VDZ Ahlrichs-VTZ
BH
                                                                            
    4    0            0.10D-14
 1      5.    1    3    3    2    1
B        0.0000000000000     0.0000000000000     0.0000000000000
 1      1.    1
H        0.0000000000000     0.0000000000000     2.3288983083247
 2      5.0   1
B        0.0000000000000     0.0000000000000     0.0000000000000
 2      1.0   1
H        0.0000000000000     0.0000000000000     2.3288983083247
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > cc2_r12_aux2_bh_lhtr.dal <<'%EOF%'

**DALTON INPUT
.RUN WAVE FUNCTION
.DIRECT
*MOLBAS
.R12AUX
**INTEGRALS
.R12
**WAVE FUNCTION
.CC
*ORBITAL INPUT
.MOSTART
 H1DIAG
*SCF INPUT
.THRESH
 1.0D-10
*CC INPUT
.CC2
.PRINT
 3  
.FROIMP
  1
  0
.THRENR
 1.0D-12
.MAX IT
 300
*CCEXCI
.THREXC
 1.D-10
.NCCEXCI
 8
.LHTR
*R12 INPUT
#.NO HYB
#.R12XXL
#.NO B
#.NO A'
#.NO 2
.CC2
 1A
**END OF DALTON INPUT
%EOF%

#######################################################################

 

#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >cc2_r12_aux2_bh_lhtr.check
cat >>cc2_r12_aux2_bh_lhtr.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

if $GREP -q "not implemented for parallel calculations" $log; then
   echo "TEST ENDED AS EXPECTED"
   exit 0
fi

#            Total SCF   energy:                   -24.8662249632 
#            Total MP2-R12/A energy:               -25.0063026940
#            Total CC2-R12/A energy:               -25.0067051367
#
#
# Excitation no.       Hartree               eV
# --------------       -------               --
#         1           -0.0600236738       -1.6333272033
#         2            0.0491876226        1.3384632598
#         3            0.2843957525        7.7388018681
#         4            0.2998230554        8.1586001230
#         5            0.3606522654        9.8138470819
#         6            0.3848739654       10.4729530476
#         7            0.4067781238       11.0689954998
#         8            0.4085893120       11.1182804361
#

CRIT1=`$GREP "Total MP2-R12/A energy:               -25.006302694" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=2
ERROR[1]="MP2-R12/A ENERGY NOT CORRECT"
CRIT2=`$GREP "Total CC2-R12/A energy:               -25.006705136" $log | wc -l`
TEST[2]=`expr	$CRIT2`
CTRL[2]=2
ERROR[2]="CC2-R12/A ENERGY NOT CORRECT"
#
CRIT3=`$GREP " 1 .*(-|-0)\.0600237 .*-1\.63333 " $log | wc -l`
TEST[3]=`expr	$CRIT3`
CTRL[3]=1
ERROR[3]="CC2-R12/A 1A1 EXCITATION ENERGY NOT CORRECT"
CRIT4=`$GREP " 2 .*( |0)\.0491876 .*1\.33846 " $log | wc -l`
TEST[4]=`expr	$CRIT4`
CTRL[4]=1
ERROR[4]="CC2-R12/A 2A1 EXCITATION ENERGY NOT CORRECT"
CRIT5=`$GREP " 3 .*( |0)\.2843958 .*7\.73880 " $log | wc -l`
TEST[5]=`expr	$CRIT5`
CTRL[5]=1
ERROR[5]="CC2-R12/A 3A1 EXCITATION ENERGY NOT CORRECT"
CRIT6=`$GREP " 4 .*( |0)\.2998231 .*8\.15860 " $log | wc -l`
TEST[6]=`expr	$CRIT6`
CTRL[6]=1
ERROR[6]="CC2-R12/A 4A1 EXCITATION ENERGY NOT CORRECT"
CRIT7=`$GREP " 5 .*( |0)\.3606523 .*9\.81385 " $log | wc -l`
TEST[7]=`expr   $CRIT7`
CTRL[7]=1
ERROR[7]="CC2-R12/A 5A1 EXCITATION ENERGY NOT CORRECT"
CRIT8=`$GREP " 6 .*( |0)\.3848740 .*10\.47295 " $log | wc -l`
TEST[8]=`expr   $CRIT8`
CTRL[8]=1
ERROR[8]="CC2-R12/A 6A1 EXCITATION ENERGY NOT CORRECT"
CRIT9=`$GREP " 7 .*( |0)\.4067781 .*11\.06900 " $log | wc -l`
TEST[9]=`expr   $CRIT9`
CTRL[9]=1
ERROR[9]="CC2-R12/A 7A1 EXCITATION ENERGY NOT CORRECT"
CRIT10=`$GREP " 8 .*( |0)\.4085893 .*11\.11828 " $log | wc -l`
TEST[10]=`expr   $CRIT10`
CTRL[10]=1
ERROR[10]="CC2-R12/A 8A1 EXCITATION ENERGY NOT CORRECT"


PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10  
do 
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done 

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM 
  exit 1
fi

%EOF%
#######################################################################
